<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 600px;
            height: 400px;
            background-color: pink;
            border: 3px solid red;
            margin: 50px auto 0;
        }

        ul,
        li,
        ol {
            list-style: none;
        }

        .box ul {
            height: 80px;
            background-color: springgreen;

            display: flex;
        }

        .box ul li {
            width: 200px;
            height: 80px;
            border: 1px solid #000;

            line-height: 80px;
            text-align: center;
            color: #fff;
            font-size: 50px;
        }

        .box ul li.active {
            background-color: tomato;
        }

        .box ol{
            width: 600px;
            height: 320px;
            overflow: hidden;
        }
        .box ol li{
            width: 600px;
            height: 320px;
            background-color: aqua;
            font-size: 60px;
            color: #fff;
            text-align: center;
            line-height: 320px;
            display: none;
        }
        .box ol li.active{
            display: block;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li class="active">1</li>
            <li>2</li>
            <li>3</li>
        </ul>
        <ol>
            <li class="active">A</li>
            <li>B</li>
            <li>C</li>
        </ol>
    </div>
    <script>
        const uLis = document.querySelectorAll("ul li")
        const oLis = document.querySelectorAll("ol li")
        for(let i = 0 ; i < uLis.length ; i++){
            uLis[i].onclick = function(){
                //使用排他思想,将ulis里面的每一个li都给删掉样式active
                for(let j = 0 ; j < uLis.length ; j++){
                    uLis[j].classList.remove("active")
                    oLis[j].classList.remove("active")
                }
                //点击那个就给那个添加样式
                uLis[i].classList.add("active")
                oLis[i].classList.add("active")
            }
        }
    </script>
</body>

</html>